package com.huaiyi.fms.open.authorization;


import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.http.HttpRequest;

import java.util.logging.Logger;

public class HttpRequestUtils {

    private static final String HEADER_ACCESS_TOKEN = "access_token";

    private static final String HEADER_OPEN_SIGN = "open_sign";

    private Logger logger = Logger.getLogger(this.getClass().getName());

    private String accessToken;

    private HttpRequest httpRequest;

    public HttpRequestUtils(String access_token, String openSign) {
        this.accessToken = access_token;
        httpRequest = new HttpRequest(new UrlBuilder());
        httpRequest.header(HEADER_ACCESS_TOKEN, accessToken);
        httpRequest.header(HEADER_OPEN_SIGN, openSign);
        httpRequest.addRequestInterceptor(httpObj -> logger.warning("发送API请求:" + httpObj.toString()));
    }


    public String getAccessToken() {
        return accessToken;
    }

    public HttpRequest getHttpRequest() {
        return httpRequest;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

}
